// otPopupDiv object
// Copyright (C) 2004, 2008 Outtask, Inc. All Rights Reserved
// <Script language="javascript">
// **************
// otPopupDiv class
// **************

if (!window.CNQR) window.CNQR = {};
if (!CNQR.MessageBox) 

CNQR.MessageBox = {
	OKCancel: [{value: 'OK', messageid: 'OK'}, {value: 0, messageid: 'Cancel'}]
	, YesNo : [{value: 'yes', messageid: 'yes'}, {value: 0, messageid: 'no'}]
	, OK : [{value: 'OK', messageid: 'OK'}]
	, Search : [{value: 'Search', messageid: 'Search'}]
	, ErrorIcon: 'error_icon'
	, WarningIcon: 'warning_icon'
	, InfoIcon: 'info_icon'
	, QuestionIcon: 'question_icon'
	, ProcessingIcon: 'processing_icon'
	, NoIcon: 'no_icon'
	, confirm: function(message, options) {
		var defaultOptions = {modal: 1, minHeight:125, attachElement: document.body, title: '', icon: CNQR.MessageBox.QuestionIcon, buttons: CNQR.MessageBox.YesNo}
		var options = Object.extend(defaultOptions, options || {})
		otShowPopupDialog(message, options.attachElement, options);
	}
	, show: function(message, options) {
		var defaultOptions = {modal: 1, attachElement: document.body, icon: CNQR.MessageBox.NoIcon}
		var options = Object.extend(defaultOptions, options || {})
		otShowPopupDialog(message, options.attachElement, options);
	}
	, alert: function(message, options) {
		var defaultOptions = {modal: 1, minHeight:125, attachElement: document.body, title: '', icon: CNQR.MessageBox.WarningIcon, buttons: CNQR.MessageBox.OK}
		var options = Object.extend(defaultOptions, options || {})
		otShowPopupDialog(message, options.attachElement, options);
	}
	, processing: function(message, options) {
		var defaultOptions = {modal: 1, minHeight:125, attachElement: document.body, icon: CNQR.MessageBox.ProcessingIcon}
		var options = Object.extend(defaultOptions, options || {})
		otShowPopupDialog(message, options.attachElement, options);
	}
}

var CQAlert = CNQR.MessageBox.alert;
var CQConfirm = CNQR.MessageBox.confirm;

var PopupDiv_List = new Array();

// public - constructor
function otPopupDiv() {
	// private
	this.outerDiv = null;	// outer
	this.iframe = null;
 	this.shadowDiv = null;
	this.div = null;
	this.identifier = null;
	this.attachType = "";
	this.attachElement = null;
	this.attachSize = null;
	this.myIndex = null;
	this.xOffset = 0;
	this.yOffset = 0;
	this.zIndex = 1000;
	this.showEffect = '';
	this.effectDuration = null;
	this.effectDirection = 'top-left';
	this.draggable = false;
	this.dragHandle = null;
	this.dragSet = false;
	this.modal = false;
	this.mask = null;
	this.maxHeight = null;
	this.minWidth = 30;
	this.minHeight = 0;
	this.autoSize = false;
	this.resizable = false;
	this.contentAttachElement = null; //append this object from the DOM to this.div for the content
	this.contentAttachParent = null;
	this.contentBody = this.div; //this is a reference to the body. for dialogs, it will be a reference to otPopupDialogContents
	this.callOnClose = null;

	// public
	this.status = false;
	this.className = null;
	this.shadowClassName = null;
	this.overflow = "hidden";
	this.isStrictDocType = (window['otUseStrict'] ? window['otUseStrict'] : false);	// set to true in vin client
	this.currentWidth = null;
	this.currentHeight = null;
	this.height = null;
	
}

// private - used to clear out any circular refs
otPopupDiv.prototype.unload = function() {
	this.unloadPopupDiv();
}

// private
otPopupDiv.prototype.unloadPopupDiv = function() {
	if (this.div != null)
		this.div.myPopup = null;
	this.outerdiv = null;
	this.iframe = null;
	this.shadowDiv = null;
	this.div = null;
	this.attachElement = null;
	this.mask = null;
	this.contentAttachElement = null;
	this.contentAttachParent = null;
	this.contentBody = null;
}

// public - call this to create the div. shadowClassName of -1 means no shadow
otPopupDiv.prototype.create = function(id, containerNode) {
	this.identifier = id;
	this.status = this.createDivs(containerNode);
	// add to list
	this.myIndex = PopupDiv_List.length;
	if (PopupDiv_List.push)
		PopupDiv_List.push(this);
	else
		PopupDiv_List[PopupDiv_List.length] = this;
		
}

// private
otPopupDiv.prototype.createDivs = function(containerNode) {
	if (!document.createElement) {
		return false;
	}
	if (!this.outerDiv && document.createElement) {
		try {
			if (typeof(containerNode) == "string")
				containerNode = document.getElementById(containerNode);
			if (containerNode == null)
				containerNode = document.body;
			// outer div
			var tempDiv = document.createElement('div');
			tempDiv.setAttribute('id', 'outer' + this.identifier);
			tempDiv.style.border = '0px';
			tempDiv.style.position = 'absolute';
			tempDiv.style.zIndex = this.zIndex;
			tempDiv.className = 'otpopupdiv';
			this.outerDiv = containerNode.appendChild(tempDiv);
			this.outerDiv.style.visibility = "hidden";
			
			// 508: Need a link after popupDiv so we can trap keypress out
			// So we don't just tab off the page
			if(CNQR.ConcurAccessible == true && containerNode == document.body) {
				tempDiv = document.createElement('a');
				tempDiv.setAttribute('href', 'javascript:void(0);');
				containerNode.appendChild(tempDiv);
			}

			// iframe (for IE to hide junk)
			if (document.all) {
				try {
					var tempIframe = document.createElement('iframe');
					tempIframe.setAttribute('id', 'if' + this.identifier);
					tempIframe.setAttribute('src', "/common/empty.html");
					tempIframe.style.border = '0px';
					tempIframe.style.width = '0px';
					tempIframe.style.height = '0px';
					tempIframe.style.marginTop = '0px';
					tempIframe.style.marginLeft = '0px';
					tempIframe.style.marginBottom = '3px';
					tempIframe.style.marginRight = '3px';
					tempIframe.style.position = 'absolute';
					this.iframe = this.outerDiv.appendChild(tempIframe);
					if (false) {
						// we are setting the 'src' attribute above instead; otherwise IE "clicks" at us for each frame
						if (tempIframe.contentWindow) {
							// For IE5.5 and IE6
							tempIframe.contentWindow.document.location.replace("/common/empty.html");
						}
						else if (tempIframe.document) {
							// For IE5
							if (tempIframe.document == window.document)
								tempIframe.src = "/common/empty.html";
							else
								tempIframe.document.location.replace("/common/empty.html");
						}
					}
				}
				catch (exception) {
					// This is for IE5 PC, which does not allow dynamic creation
					// and manipulation of an iframe object. Instead, we'll fake
					// it up by creating our own objects.
					var iframeHTML = '<iframe id="if' + this.identifier + '" style="';
					iframeHTML += 'border:0px;';
					iframeHTML += 'width:0px;';
					iframeHTML += 'height:0px;';
					iframeHTML += 'margin-top:0px;';
					iframeHTML += 'margin-left:0px;';
					iframeHTML += 'margin-bottom:3px;';
					iframeHTML += 'margin-right:3px;';
					iframeHTML += 'position:absolute;';
					iframeHTML += '" src="/common/empty.html"></iframe>';
					this.outerDiv.innerHTML += iframeHTML;
					this.iframe = document.getElementById("if" + this.identifier);
				}
			}

			// shadow
			
			if (document.all && this.hackIEShadow && this.shadowClassName != -1) 
			{
				//ie specific version, because the shadow div causes problems with scriptaculous. 
				this.outerDiv.style.filter = "progid:DXImageTransform.Microsoft.DropShadow(color=#798179,offX=2,offY=2)";
			}
			else if (this.shadowClassName != -1) {
				tempDiv = document.createElement('div');
				tempDiv.setAttribute('id', 'shadow' + this.identifier);
				if (this.shadowClassName != null && this.shadowClassName != "")
					tempDiv.className = this.shadowClassName;
				else {
					tempDiv.style.background = 'gray';
					tempDiv.style.opacity = "0.5";
					tempDiv.style.filter = "alpha(opacity=50)";
					tempDiv.style.border = '0px';
				}
				tempDiv.style.position = 'absolute';
				tempDiv.style.marginTop = '3px';
				tempDiv.style.marginLeft = '3px';
				tempDiv.style.marginBottom = '0px';
				tempDiv.style.marginRight = '0px';
				this.shadowDiv = this.outerDiv.appendChild(tempDiv);
			}

			// content
			tempDiv = document.createElement('div');
			tempDiv.setAttribute('id', this.identifier);
			tempDiv.setAttribute('tabindex', '-1');
			if (this.className != null && this.className != "") {
				tempDiv.className = this.className;
				// 508: Help should have role "tooltip" but that needs the calling element to be labeled
				// with the id of the tip...we should investigate implementing later
				// Reader announces "alert"so user has indication of what happened
				switch (this.className)
				{
					case 'popupdialog':
					case 'popuphelp':
						tempDiv.setAttribute('role', 'alert');
						break;
					default:
						break;
				}
			} else {
				tempDiv.style.border = '1px';
				tempDiv.style.borderStyle = 'solid';
				tempDiv.style.borderColor = 'black';
				tempDiv.style.backgroundColor = 'white';
				tempDiv.style.fontFamily = 'Tahoma, sans-serif';
				tempDiv.style.fontSize = '8pt';
				tempDiv.style.fontStyle = 'normal';
				tempDiv.style.fontWeight = 'normal';
			}
			tempDiv.style.position = 'absolute';
			tempDiv.style.marginTop = '0px';
			tempDiv.style.marginLeft = '0px';
			tempDiv.style.marginBottom = '3px';
			tempDiv.style.marginRight = '3px';
			tempDiv.style.cursor = "default";
			// mozilla mac bug with scrollbars - always start out with overflow hidden
			// there are still item selection issues -- nothing I can do. First few clicks in
			// the "hidden" areas don't take
			tempDiv.style.overflow = ((this.overflow == null || this.overflow == "" || this.doMacSbFix() == true) ? "hidden" : this.overflow);
			this.div = this.outerDiv.appendChild(tempDiv);
			tempDiv.myPopup = this;

		} catch(exception) {
			this.message = exception.message;
			return false;
		}
	}
	return true;
}

// public - is shown
otPopupDiv.prototype.isVisible = function () {
	return (this.outerDiv.style.visibility  == "visible");
}

// public - sets position
otPopupDiv.prototype.setPos = function(left, top) {
	this.outerDiv.style.left = this.parseSize(left) + this.xOffset + "px";
	this.outerDiv.style.top = this.parseSize(top) +  this.yOffset + "px";
}

// private
otPopupDiv.prototype.parseSize = function(s) {
	var r = 0;
	if (this.rexp == null)
		this.rexp = /^(\d+)(px)?$/i;
	if (s != null && this.rexp.test(s))
		r = parseFloat(s.toString().replace(this.rexp, "$1"));
	return r;
}

// public - sets width
otPopupDiv.prototype.setWidth = function(width) {
	var b = 0;
	var bs = 0;
	width = this.parseSize(width);
	width = (width < this.minWidth) ? this.minWidth : width;
	
	this.currentWidth = width;
	
	if (!document.all || this.isStrictDocType) {
		b = this.parseSize(this.div.style.borderLeftWidth) + this.parseSize(this.div.style.borderRightWidth) + this.parseSize(this.div.style.paddingLeft) + this.parseSize(this.div.style.paddingRight);
		if (this.shadowDiv != null)
			bs = this.parseSize(this.shadowDiv.style.borderLeftWidth) + this.parseSize(this.shadowDiv.style.borderRightWidth) + this.parseSize(this.shadowDiv.style.paddingLeft) + this.parseSize(this.shadowDiv.style.paddingRight);
	}
	this.outerDiv.style.width = width + "px";
	if (this.iframe != null)
		this.iframe.style.width = (width - b >= 0 ? width - b : 0) + "px";
	if (this.shadowDiv != null)
		this.shadowDiv.style.width = (width - bs >= 0 ? width - bs : 0) + "px";
	this.div.style.width = (width - b >= 0 ? width - b : 0) + "px";
/*	debugger;
//	if (this.contentBody) {
		this.contentBody.style.overflowX = 'hidden';
		offDiff = this.contentBody.offsetWidth > width ? this.contentBody.offsetWidth : 0
		tmpWidth = width - b - offDiff - this.parseSize(this.div.style.marginRight) - this.parseSize(this.div.style.marginLeft);
//		OTDebugWrite('tmpWidth = '+tmpWidth);
//		OTDebugWrite('this.contentBody.style.offsetWidth = '+this.contentBody.offsetWidth);
		this.contentBody.style.width = tmpWidth + "px";
//		OTDebugWrite('this.contentBody.offsetWidth = '+this.contentBody.offsetWidth);
	}
*/
}

// public - sets height
otPopupDiv.prototype.setHeight = function(height, contentHeight) {
	//if content height is passed in, and smaller than the height, we need scroll bars
	var b = 0;
	var bs = 0;
	var statusHeight = (this.statusBar) ? this.statusBar.offsetHeight : 0;

	height = this.parseSize(height);

	//don't let height be smaller than min height	
	height = (height < this.minHeight) ? this.minHeight : height;

	contentHeight = (contentHeight) ? this.parseSize(contentHeight) : contentHeight;
	
	var maxHeight = this.maxHeight;
	if (contentHeight && height != contentHeight) {
		//use the height for the maxheight as long as it is less than the normal max height
		maxHeight = (maxHeight && maxHeight < height) ? maxHeight : height;
		height = (height > contentHeight) ? height : contentHeight;
	}
	else {
		maxHeight = (maxHeight == null) ? height : maxHeight;
	}

	//maxHeight-=statusHeight;

	//don't let height be smaller than min height	
	height = (height < this.minHeight) ? this.minHeight : height;
	
	//OTDebugWrite('h:' + height + ', contentHeight: ' + contentHeight + ', max:' + maxHeight);
	
	if (maxHeight && height + statusHeight >= maxHeight) {
		height = maxHeight;
		//OTDebugWrite('hNew:' + height + ', contentHeight: ' + contentHeight + ', max:' + maxHeight);

		if (this.contentBody && this.contentBody.offsetHeight) 
		{	
			//this.contentBody.style.height = ""; //reset the height
			//checking this.contentBody.offsetHeight > 0 because if the item is display:none, the height will be 0
			var contentH = this.contentBody.offsetHeight;

			//determine how much of the height is not the content
			var notContentH = this.parseSize(this.div.offsetHeight) - this.parseSize(contentH);
			notContentH+= statusHeight;

			//this will be the new contentBody height
			var paddingTop = 2; //-2 is the default padding/margin
			if (this.contentBody.getStyle) { /*prototype.js*/
				paddingTop = parseInt(this.contentBody.getStyle('padding-top'),10);
				paddingTop += parseInt(this.contentBody.getStyle('padding-bottom'),10);
			}
			var newContentH = maxHeight - notContentH -paddingTop;
			//OTDebugWrite('maxH: ' + maxHeight + ', totalh: ' + this.div.offsetHeight + ', content: ' + contentH + ', newheight: ' + newContentH);
			if (newContentH < 0) {
				newContentH = 0;
			}
			this.contentBody.style.height = newContentH + 'px'; 
			this.contentBody.style.overflow = 'auto'; //allow for a scrollbar
		}
	}

	if (!document.all || this.isStrictDocType) {
		b = this.parseSize(this.div.style.borderTopWidth) + this.parseSize(this.div.style.borderBottomWidth) + this.parseSize(this.div.style.paddingTop) + this.parseSize(this.div.style.paddingBottom);
		if (this.shadowDiv != null)
			bs = this.parseSize(this.shadowDiv.style.borderTopWidth) + this.parseSize(this.shadowDiv.style.borderBottomWidth) + this.parseSize(this.shadowDiv.style.paddingTop) + this.parseSize(this.shadowDiv.style.paddingBottom);
	}
	this.outerDiv.style.height = height + "px";
	if (this.iframe != null)
		this.iframe.style.height = (height - b >= 0 ? height - b : 0) + "px";
	if (this.shadowDiv != null)
		this.shadowDiv.style.height = (height - bs >= 0 ? height - bs : 0) + "px";
	
	this.currentHeight = (height - b >= 0 ? height - b : 0);
	this.div.style.height = this.currentHeight + "px";
	 
}

// public - sizes div (ignores null parameters)
otPopupDiv.prototype.setRect = function(left, top, width, height) {
	if (top != null && left != null)
		this.setPos(left, top);
	if (width != null)
		this.setWidth(width);
	if (height != null)
		this.setHeight(height);
}

// private - detect if mozilla mac fix needed
otPopupDiv.prototype.doMacSbFix = function() {
	if (!document.all && (this.overflow == "scroll" || this.overflow == "auto") && navigator.platform.toLowerCase().indexOf("mac") >= 0 && navigator.userAgent.toLowerCase().indexOf("safari") < 0)
		return true;
	else
		return false;
}

// public - shows div
otPopupDiv.prototype.show = function() {
	// mozilla mac bug with scroll bars
	if (this.doMacSbFix())
		this.div.style.overflow = this.overflow;
	this.reattach();	
	this.showMask();
	if (window['Draggable'] && this.draggable && !this.dragSet)
	{
		var dHandle = $(this.dragHandle);
		new Draggable(this.outerDiv, {handle: dHandle})
	}
	// 508: Keyboard accessibility - set element to take focus on close
	if (CNQR.keyLinkElement != null) CNQR.popupLinkElement = CNQR.keyLinkElement;
	
	if (window['Effect'] && this.showEffect) {
		var me = this; // closures below won't recognize 'this'
		var effectDuration = this.effectDuration;
		switch (this.showEffect)
		{
			case 'grow':
				new Effect.Grow(me.outerDiv, 
				{
					direction: me.effectDirection
					, duration: (me.effectDuration || .1)
					, beforeStart: function(effect) {
						me.outerDiv.style.visibility = 'visible';
						me.outerDiv.style.display = 'none';
					}
					, afterFinish: function(effect) {
						me.onshow(me);
					}
				});
				break;
			case 'slide':
			case 'blind':
				var effectNm = (this.showEffect == 'slide') ? 'SlideDown': 'BlindDown';
				
				me.outerDiv.style.visibility = 'visible';
				me.outerDiv.style.display = 'none';	

				new Effect[effectNm](me.outerDiv,
				{
					duration: (effectDuration || 1)
					, beforeStart: function(effect) {}
					, afterFinish: function(effect) {me.onshow(me);}
				});	
				break;			
			default: /*appear*/
				me.outerDiv.style.visibility = 'visible';
				me.outerDiv.style.display = 'none';	
				new Effect.Appear(me.outerDiv,
				{
					duration: (effectDuration || 1)
					, beforeStart: function(effect) {}
					, afterFinish: function(effect) {
						me.onshow(me);
					}
				});	
		}
	}
	else
	{
		this.outerDiv.style.visibility = "visible";
		this.onshow(this);
	}
}

// public - hides div
otPopupDiv.prototype.hide = function() {
	// mozilla mac bug with scroll bars
	if (this.doMacSbFix())
		this.div.style.overflow = "hidden";
		
	if (window['Effect'] && this.showEffect) {
		//need to special case 'grow' because effects.js didn't have it in the list of pairs
		var effectName = (this.showEffect == 'grow') ? 'Shrink' : Effect.PAIRS[this.showEffect][1];
		var me = this;
		new Effect[effectName](me.outerDiv, 
		{
			direction: me.effectDirection
			, duration: (me.effectDuration || .7)
			, beforeStart: function(effect) {}
			, afterFinish: function(effect) {
				//need to do the style changes b/c next time you show it, it needs to be able to determine the height
				me.outerDiv.style.visibility = 'hidden';
				me.outerDiv.style.display = '';
				me.hideMask();
				me.beforeOnHide(me);
				me.onhide(me);
			}
		});
	}
	else {
		this.outerDiv.style.visibility = "hidden";
		this.hideMask();
		this.beforeOnHide(this);
		this.onhide(this);
	}
}

// event - override if you want
otPopupDiv.prototype.onshow = function() {
	popupDialog_onshow(this);
}

otPopupDiv.prototype.beforeOnHide = function () {}

// event - override if you want
otPopupDiv.prototype.onhide = function() {
}

// public
otPopupDiv.prototype.setHTML = function(html) {
	this.div.innerHTML = html;
	this.resizeDiv();
}

otPopupDiv.prototype.resizeDiv = function() {
	this.div.style.height = "";	// makes it auto-size height
	if (this.contentBody) {
		this.contentBody.style.height = "";
	}
	if (this.autoSize) {
		this.div.style.width = "";	/* makes it auto-size width */
		var op = this.div.style.position;
		this.div.style.position = 'absolute'; /*otherwise it would be width:100% */
//		this.testcrap()
		this.setWidth(this.div.offsetWidth);
		this.div.style.position = op;
	}
	else {
//		OTDebugWrite('otPopupDialogContents1:'+$('otPopupDialogContents').offsetWidth);
		this.setWidth(this.width || this.currentWidth);
//		OTDebugWrite('otPopupDialogContents2:'+$('otPopupDialogContents').offsetWidth);
	}
	var statusHeight = (this.statusBar) ? this.statusBar.offsetHeight : 0;
	var tmpH = (this.height || this.div.offsetHeight + statusHeight);
	this.setHeight(tmpH, this.div.offsetHeight); // apply new height to other elements
}

otPopupDiv.prototype.testcrap = function() {

	OTDebugWrite('BAR: ' + $('otPopupDialogStatus') + ', ' + this.statusBar + ', ' + this.contentBody);
	if ($('otPopupDialogStatus')) {
		$('otPopupDialogStatus').style.display = 'none';
	}
	
	var divs = this.div.getElementsByTagName('*');
	for (var i=0; i< divs.length; i++)
	{
		var d = divs[i]
		if (d.id == "otPopupDialogContents") {
			OTDebugWrite(d.id + ' - ' + d.tagName + ' - ' + divs[i].style.width + ' : ' + Element.getStyle(divs[i], 'width'));
		}
	}
}

// public
otPopupDiv.prototype.resetHeight = function() {
	this.div.style.height = "";	// makes it auto-size height
	if (this.contentBody) {
		this.contentBody.style.height = "";
	}
	var statusHeight = (this.statusBar) ? this.statusBar.offsetHeight : 0;
	var tmpH = (this.height || this.div.offsetHeight + statusHeight);
	this.setHeight(tmpH, this.div.offsetHeight); // apply new height to other elements
}

// public - subclasses implement this
otPopupDiv.prototype.forwardEvent = function(event) {
}

// public - positions div below element
otPopupDiv.prototype.positionBelow = function(element, width) {
	if (typeof(element) == "string")
		element = document.getElementById(element);
	if (width != null)
		width = this.parseSize(width);
	this.attachType = "below";
	this.attachElement = element;
	this.attachSize = width;
	
	var W = this.parseSize(element.offsetWidth);
	var H = this.parseSize(element.offsetHeight);
	var L = this.parseSize(element.offsetLeft - element.scrollLeft);
	var T = this.parseSize(element.offsetTop - element.scrollTop);
	var p = element.offsetParent;
	var s
	while (p != null && p != document.body) {
		L += this.parseSize(p.offsetLeft) - this.parseSize(p.scrollLeft);
		T += this.parseSize(p.offsetTop) - this.parseSize(p.scrollTop);
		p = p.offsetParent;
	}
	
	//OTDebugWrite('height: ' + H + '; width: ' + W + '; t:' + T + '; L: ' + L);

	if (this.isRightClickMenu) {
		//test to see if we're below the window. If so, positionabove instead.
		var off = this.getPageOffset();
		var sz = this.getWindowSize();
		var itemW = this.parseSize(this.outerDiv.offsetWidth);
		var itemH = this.parseSize(this.outerDiv.offsetHeight);
		//OTDebugWrite('topheight: ' + (T+itemH) + ';elementheight: ' + H + '; t:' + T + '; itemH: ' + itemH + '; windowtop: ' + sz[1]);
		if ((L + W) > sz[0])
			L -= (L + W - sz[0]);
		if ((T + itemH + 8) > sz[1]){
			T -= (itemH + H);
		}
	}
	//OTDebugWrite('topheight: ' + (T+itemH) + ';height: ' + H + '; t:' + T + '; itemH: ' + itemH + '; windowtop: ' + sz[1]);

	
	this.setPos(L, T + H);
	if (width != null)
		W = width;
	this.setWidth(W);
}
// public - positions div's top on top of element
otPopupDiv.prototype.positionTop = function(element, width) {
	if (typeof(element) == "string")
		element = document.getElementById(element);
	if (width != null)
		width = this.parseSize(width);
	this.attachType = "top";
	this.attachElement = element;
	this.attachSize = width;
	var W = this.parseSize(element.offsetWidth);
	var L = this.parseSize(element.offsetLeft);
	var T = this.parseSize(element.offsetTop);
	var p = element.offsetParent;
	
	while (p != null && p != document.body) {
		L += this.parseSize(p.offsetLeft) - this.parseSize(p.scrollLeft);
		T += this.parseSize(p.offsetTop) - this.parseSize(p.scrollTop);		
		p = p.offsetParent;
	}
	
	this.setPos(L, T);
	if (width != null)
		W = width;
	this.setWidth(W);
}

// public - positions div's bottom above the top of the element
otPopupDiv.prototype.positionAbove = function(element, width) {
	if (typeof(element) == "string")
		element = document.getElementById(element);
	if (width != null)
		width = this.parseSize(width);
	this.attachType = "above";
	this.attachElement = element;
	this.attachSize = width;
	var W = this.parseSize(element.offsetWidth);
	var L = this.parseSize(element.offsetLeft);
	var T = this.parseSize(element.offsetTop);
	var p = element.offsetParent;
	
	while (p != null && p != document.body) {
		L += this.parseSize(p.offsetLeft) - this.parseSize(p.scrollLeft);
		T += this.parseSize(p.offsetTop) - this.parseSize(p.scrollTop);		
		p = p.offsetParent;
	}
	
	this.setPos(L, T - this.div.offsetHeight - element.offsetHeight);
	if (width != null)
		W = width;
	this.setWidth(W);
}

// public - positions div on top of element
otPopupDiv.prototype.positionCenter = function(width) {
	if (width != null)
		width = this.parseSize(width);

	if (!width) width = this.outerDiv.offsetWidth;
	if (!width) width = 300;
	this.attachType = "center";
	this.attachElement = null;
	this.attachSize = width;

	var sWidth = document.body.clientWidth;
	var sHeight = document.body.clientHeight;
	var oHeight = this.parseSize(this.outerDiv.offsetHeight);
	if (!oHeight) oHeight = this.parseSize(this.outerDiv.style.height);
	//var W = ( width > sWidth)? sWidth : width;
	//var H = (oHeight > sHeight)? sHeight : oHeight;
	var L = parseInt((sWidth-width)/2, 10);
	var T = parseInt((sHeight-oHeight)/2 - 40, 10);
	
	this.setWidth(width);
	this.setPos(L, T);
}

// public
otPopupDiv.prototype.positionWindowCenter = function(width) {
	if (width != null)
		width = this.parseSize(width);

	if (!width) width = this.outerDiv.offsetWidth;
	if (!width) width = 300;
	this.attachType = "windowcenter";
	this.attachElement = null;
	this.attachSize = width;

	var windowsize = this.getWindowSize();
	var scroll = this.getPageOffset();
	var oHeight = this.parseSize(this.outerDiv.offsetHeight);
	if (!oHeight) oHeight = this.parseSize(this.outerDiv.style.height);
	var L = parseInt(scroll[0] + (windowsize[0]-width)/2, 10);
	var T = parseInt(scroll[1] + (windowsize[1]-oHeight)/2 - 40, 10);

	this.setWidth(width);
	this.setPos(L, T);
}

// public - positions div right of element
otPopupDiv.prototype.positionRight = function(element, height) {
	if (typeof(element) == "string")
		element = document.getElementById(element);
	if (height != null)
		height = this.parseSize(height);
	this.attachType = "right";
	this.attachElement = element;
	this.attachSize = height;
	var W = this.parseSize(element.offsetWidth);
	var H = this.parseSize(element.offsetHeight);
	var L = this.parseSize(element.offsetLeft);
	var T = this.parseSize(element.offsetTop);
	var p = element.offsetParent;
	while (p != null && p != document.body) {
		L += this.parseSize(p.offsetLeft) - this.parseSize(p.scrollLeft);
		T += this.parseSize(p.offsetTop) - this.parseSize(p.scrollTop);		
		p = p.offsetParent;
	}

	this.setPos(L + W, T);
	if (height != null)
		H = height;
	this.setHeight(H);
}

// public - make popup help easy
otPopupDiv.prototype.showPopup = function(html, type, obj) {
	var ev, L, T, W, H, off, sz;
	if (html != null)
		this.setHTML(html);
	W = (this.outerDiv.offsetWidth) ? this.outerDiv.offsetWidth : this.attachSize;
	switch (type.toLowerCase()) {
		case "positionright":
			if (obj != null)
				this.positionRight(obj, this.outerDiv.offsetHeight);
			break;
		case "positionbelow":
			if (obj != null)
				this.positionBelow(obj, W);
			break;
		case "positiontop":
			if (obj != null)
				this.positionTop(obj, W);
			break;
		case "positionabove":
			if (obj != null)
				this.positionAbove(obj, W);
			break;
		case "positioncenter":
				this.positionCenter(W);
			break;
		case "windowcenter":
				this.positionWindowCenter(W);
			break;
		case "coordinate":
			if (obj != null && obj.length && obj.length == 2)
				this.setPos(obj[0], obj[1]);
			break;
		case "event":
			if (obj != null) {
				ev = obj;
				if (window.event)
					ev = window.event;
				// element position
				L = ev.clientX;
				T = ev.clientY;
				// element size
				W = this.parseSize(this.outerDiv.offsetWidth);
				H = this.parseSize(this.outerDiv.offsetHeight);
				// window/page info
				sz = this.getWindowSize();
				off = this.getPageOffset();
				// fit to screen
				if ((L + W) > sz[0])
					L -= (L + W - sz[0]);
				if ((T + H) > sz[1])
					T -= (T + H - sz[1]);
				// adjust for page offset
				L += off[0];
				T += off[1];
				this.setPos(L, T);
			}
			break;
	}
	this.show();
}

// public - make popup help easy
otPopupDiv.prototype.hidePopup = function() {
	if (this.noHide) {
		this.noHide = false;
	} else {
		this.hide();
		
		// 508: If user manually closes dialog then send focus back
		// This allows popup div to open other popup divs & get focus
		if (CNQR.popupLinkElement != null)
		{
			CNQR.popupLinkElement.focus();
			CNQR.popupLinkElement = null;
		}

		if (this.callOnClose)
		  this.callOnClose();
	}
}

// public - gets browser page offset (scrolling)
otPopupDiv.prototype.getPageOffset = function() {
	var x = 0;
	var y = 0;
	if (window.pageXOffset && window.pageYOffset) {
		// netscape
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		// DOM
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		// ie6 strict
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	return [x, y];
}


// public - gets browser window inner size
otPopupDiv.prototype.getWindowSize = function() {
	var x = 0;
	var y = 0;
	if (window.innerWidth && window.innerHeight) {
		// netscape
		x = window.innerWidth;
		y = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		// ie6 strict
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		// DOM
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return [x, y];
}

otPopupDiv.prototype.getWindowDimensions = function() {
	var arr = this.getWindowSize();
	return {width: arr[0], height:arr[1]}
}

// private - reattach
otPopupDiv.prototype.reattach = function() {
	if (this.attachElement != null) {
		try {
			if (this.attachType == "below")
				this.positionBelow(this.attachElement, this.attachSize);
			else if (this.attachType == "right")
				this.positionRight(this.attachElement, this.attachSize);
			else if (this.attachType == "top")
				this.positionTop(this.attachElement, this.attachSize);
			else if (this.attachType == "above")
				this.positionAbove(this.attachElement, this.attachSize);
			else if (this.attachType == "center")
				this.positionCenter(this.attachSize);
			else if (this.attachType == "windowcenter")
				this.positionWindowCenter(this.attachSize);
			}
		catch (err)
		{
			//do nothing for now :(
		}
	}
}

otPopupDiv.prototype.hideMask = function() {
	if (this.modal && this.mask) {
		this.mask.tabIndex = -1;
		this.mask.style.display = "none";

		//neither of these regular expressions were working right in IE.		
		//var pattern = "(\\s|^)(masked)(\\s|$)";
		//var regex2 = new RegExp(pattern);regex2.global=true;
		//document.body.className = document.body.className.replace(regex2, "$3");

		//var re = new RegExp('(?:^|\\s+)masked(?:\\s+|$)', 'g');
		//document.body.className = document.body.className.replace(re, ' ');
		var arrClsNames = document.body.className.split(' ');
		for (var i=0; i < arrClsNames.length; i++)
		{
			if (arrClsNames[i] == 'masked') {
				delete arrClsNames[i]; //wipe out the value
			}
		}
		document.body.className = arrClsNames.join(' ');
	}
}

otPopupDiv.prototype.showMask = function() {
	if (this.modal) {
		this.buildMask();
		document.body.className+= " masked";
		this.resizeMask();
		this.mask.style.display = "block";
		this.mask.tabIndex = 0;
	}
}

otPopupDiv.prototype.resizeMask = function() {
	if (this.mask) {	
		//note, this only works in quirks mode
		var h = [document.body.scrollHeight, document.body.clientHeight].sort(function(a, b){return(a-b);})[1];
		var w = [document.body.clientWidth, document.body.scrollWidth].sort(function(a, b){return(a-b);})[1];
	
		this.mask.style.height = h + 'px';
		this.mask.style.width = w + 'px';
	}
}

otPopupDiv.prototype.buildMask = function() {
	if (! this.mask) {
		this.mask = document.createElement("DIV");
		this.mask.id = this.id + "_mask";
		this.mask.className = "mask";
		this.mask.innerHTML = "&nbsp;";
		this.mask.style.zIndex = 998;

		var maskClick = function(e, obj) {
			stopEvent(e); //defined in functions.js
		}

		//eventually i want to find a good way to push focus back to the dialog box via something like:
		//this.mask.onfocus = function() {/*send focus back to the popupdialog*/}

		addEvent(this.mask, 'click', maskClick.bindAsEventListener(this));
		addEvent(window, 'resize', this.resizeMask.bindAsEventListener(this));
		
		if (window.opera) {
			this.mask.style.backgroundColor = "transparent";
		}
		document.body.appendChild(this.mask);
	}
}

// private - used to keep window attached when user does Ctrl- or Ctrl+ in Mozilla
function PopupDiv_ListenForReattach(ev) {
	var keyCode = 0;
	var isCtrl = false;
	if (window.event) {
		keyCode = window.event.keyCode;
		isCtrl = window.event.ctrlKey;
	}
	else if (ev) {
		keyCode = ev.which;
		isCtrl = ev.ctrlKey;
	}
	if (isCtrl && (keyCode == 61 || keyCode == 109))
		PopupDiv_Reattach();
}

// private - reattach items
function PopupDiv_Reattach() {
	for (var i = 0; i < PopupDiv_List.length; i++) {
		PopupDiv_List[i].reattach();
	}
}

// private - unload popupdivs
function PopupDiv_unload() {
	for (var i = 0; i < PopupDiv_List.length; i++) {
		if (PopupDiv_List[i] != null) {
			PopupDiv_List[i].unload();
			PopupDiv_List[i] = null;
		}
	}
}

// listen for mozilla events
if (window.addEventListener)
	window.addEventListener("keyup", PopupDiv_ListenForReattach, false);

// listen for resize events
if (window.addEventListener)
	window.addEventListener("resize", PopupDiv_Reattach, false);
else if (window.attachEvent)
	window.attachEvent("onresize", PopupDiv_Reattach);
else {
	if (typeof(window.onresize) == "function") {
		var PopupDiv_existingOnResize = window.onresize;
		window.onresize = function() {
			PopupDiv_existingOnResize();
			PopupDiv_Reattach();
		}
	}
	else
		window.onresize = PopupDiv_Reattach;
}

// add unload handler to clear circular refs -- should help browser memory management
if (window.addEventListener)
	window.addEventListener("unload", PopupDiv_unload, false);
else if (window.attachEvent)
	window.attachEvent("onunload", PopupDiv_unload);
else {
	if (typeof(window.onunload) == "function") {
		var PopupDiv_existingOnUnload = window.onunload;
		window.onunload = function() {
			PopupDiv_existingOnUnload();
			PopupDiv_unload();
		}
	}
	else
		window.onunload = PopupDiv_unload;
}




// ***************
// PopupList class
// ***************

PopupList.prototype = new otPopupDiv();
PopupList.prototype.constructor = PopupList;

// public - constructor
function PopupList() {
	// private
	this.selectedIndex = -1;
	this.items = null;
	this.divs = null;

	// public
	this.maxRows = 10;
	this.actualRows = 0;
	this.itemClassName = null;
	this.selectedItemClassName = null;
	this.tagName = 'DIV';

}

// private - used to clear out any circular refs
PopupList.prototype.unload = function() {
	this.unloadPopupList();
	this.unloadPopupDiv();
}

PopupList.prototype.unloadPopupList = function() {
	if (this.divs != null) {
		for (var i = 0; i < this.divs.length; i++)
			this.divs[i] = null;
	}
	this.divs = null;
	this.items = null;
}

// public - number of items
PopupList.prototype.getLength = function() {
	if (this.divs == null)
		return 0;
	else
		return this.actualRows;
}

// internal
function PopupList_mouseover(ev) {
	if (window.event)
		ev = window.event;
	var div = ev.target;
	if (div == null)
		div = ev.srcElement;

	var This = div.parentNode.myPopup;
	while (This == null && div.parentNode != null) {
		div = div.parentNode;
		This = div.parentNode.myPopup;
	}
	
	var i = parseInt(div.getAttribute("id").substring(This.identifier.length));
	This.hilight(i);
}

// internal
function PopupList_mouseout(ev) {
	if (window.event)
		ev = window.event;
	var div = ev.target;
	if (div == null)
		div = ev.srcElement;
	var This = div.parentNode.myPopup;
	while (This == null && div.parentNode != null) {
		div = div.parentNode;
		This = div.parentNode.myPopup;
	}
	This.hilight(-1);
}

// internal
function PopupList_click(ev) {
	if (window.event)
		ev = window.event;
	var div = ev.target;
	if (div == null)
		div = ev.srcElement;
	var This = div.parentNode.myPopup;
	while (This == null && div.parentNode != null) {
		div = div.parentNode;
		This = div.parentNode.myPopup;
	}
	var i = parseInt(div.getAttribute("id").substring(This.identifier.length));
	This.select(i);
	This.onchoose();
}

// public - set array of items
PopupList.prototype.setItems = function(arr) {
	if (this.divs == null)
		this.divs = new Array();
	if (arr == null || arr.length == 0) 
		this.clear();
	else {
		this.items = arr;
		var L = arr.length;
		if (this.overflow != "scroll" && this.overflow != "auto" && L > this.maxRows)
			L = this.maxRows;
		// add new divs
		for (var i = this.divs.length; i < L; i++) {
			var tempDiv = document.createElement(this.tagName);
			tempDiv.setAttribute('id', this.identifier + i.toString());
			if (this.itemClassName != null && this.itemClassName != "")
				tempDiv.className = this.className;
			else {
				tempDiv.style.backgroundColor = 'white';
				tempDiv.style.fontFamily = 'Tahoma, sans-serif';
				tempDiv.style.fontSize = '8pt';
				tempDiv.style.fontStyle = 'normal';
				tempDiv.style.fontWeight = 'normal';
				tempDiv.style.overflow = 'hidden';
				tempDiv.style.whiteSpace = 'nowrap';
				tempDiv.style.paddingTop = '1px';
				tempDiv.style.paddingBottom = '1px';
			}
			tempDiv.setAttribute("mypoplist", this.identifier);
			tempDiv.setAttribute("position", i);
			tempDiv.style.position = 'relative';
			tempDiv.style.overflow = "hidden";
			if (this.tagName == 'A') {
				tempDiv.style.display = 'block';
				tempDiv.href = '#';
				tempDiv.style.textDecoration = 'none';
			}
			tempDiv.onmouseover = PopupList_mouseover;
			tempDiv.onmouseout = PopupList_mouseout;			
			tempDiv.onfocus = PopupList_mouseover;
			tempDiv.onblur = PopupList_mouseout;
			tempDiv.onclick = PopupList_click;
			
			this.divs[i] = this.div.appendChild(tempDiv);
		}
		// remove extra divs
		for (var i = this.divs.length - 1; i >= L; i--) {
			//this.div.removeChild(this.divs[i]);	// hide instead
			//this.divs[i].style.visibility = 'hidden';
			this.divs[i].style.display = 'none';
		}
		//this.divs.length = L;	// hide instead
		// adjust scroll style
		if (this.overflow == "scroll" || this.overflow == "auto") {
			if (this.divs.length > this.maxRows && (!this.doMacSbFix() || this.isVisible()))
				this.div.style.overflow = this.overflow;
			else
				this.div.style.overflow = "hidden";
		}
		// draw
		this.actualRows = L;
		for (var i = 0; i < L; i++) {
			this.divs[i].style.visibility = '';		// show again since hidden before
			this.divs[i].style.display = 'block';	// show again since hidden before
			this.ondrawitem(i);
		}
		// make none selected
		this.select(-1);
		// reset size
		var totalH = 0;
		var maxS = this.maxRows;
		if (maxS > this.divs.length)
			maxS = this.divs.length;
		if (this.overflow != "scroll" && this.overflow != "auto")
			maxS = L;
		for (var i = 0; i < maxS; i++)
			totalH += this.parseSize(this.divs[i].offsetHeight);
		this.setHeight(totalH + 2);		
	}
}

// public - select an item
PopupList.prototype.select = function(index) {
	if (this.divs != null) {
		if (index >= 0 && index < this.actualRows)
			this.selectedIndex = index;
		else
			this.selectedIndex = -1;
		this.hilight(this.selectedIndex);
		if (index >= 0 && index < this.actualRows) {
			if (this.divs[this.selectedIndex].scrollIntoView && (this.overflow == "scroll" || this.overflow == "auto"))
				this.divs[this.selectedIndex].scrollIntoView(false);
		}
		this.onchange();
	}
}

// private - hilight an item
PopupList.prototype.hilight = function(index) {
	if (this.divs != null) {
		for (var i = 0; i < this.actualRows; i++)
			this.oncoloritem(i, index == i);
	}
}

// public - clear list
PopupList.prototype.clear = function() {
	if (this.divs == null)
		this.divs = new Array();
	this.selectedIndex = -1;
	this.items = null;
	this.actualRows = 0;
	for (var i = this.divs.length - 1; i >= 0; i--) {
		//this.divs[i].style.visibility = 'hidden';
		this.divs[i].style.display = 'none';
		// this.div.removeChild(this.divs[i]);
	}
	// this.divs.length = 0;
	this.setHeight(0);
}

// event - when selected item changes
PopupList.prototype.onchange = function() {
}

// event - when user clicks or hits enter
PopupList.prototype.onchoose = function() {
}

// event - when item needs to be rendered
PopupList.prototype.ondrawitem = function(index) {
	this.divs[index].innerHTML = "&nbsp;" + this.items[index];
}

// event - change to make when an item is selected/deselected
PopupList.prototype.oncoloritem = function(index, hilight) {
	if (hilight) {
		if (this.selectedItemClassName != null && this.selectedItemClassName != "")
			this.divs[index].className = this.selectedItemClassName;
		else {
			//this.divs[index].style.backgroundColor = "lightsteelblue";
			var els = this.divs[index].style;
			els.border = "1px solid #A7D7EB";
			els.padding = "3px 1px";
			els.margin = "0px 2px";
			els.backgroundColor = "#E6F1FA";
		}
	}
	else {
		if (this.itemClassName != null && this.itemClassName != "")
			this.divs[index].className = this.itemClassName;
		else {
			//this.divs[index].style.backgroundColor = "white";
			var els = this.divs[index].style;
			els.borderWidth = "0px 0px 0px 0px";
			els.padding = "4px 4px";
			els.margin = "0px 0px 0px 0px";
			els.backgroundColor = "white";
		}
	}
}

// public - accepts keyboard input
PopupList.prototype.forwardEvent = function(event) {
	var keyCode;
	var ev = event;
	if (window.event) {
		ev = window.event;
		keyCode = ev.keyCode;
	}
	else
		keyCode = ev.which;
	if (this.divs != null && this.outerDiv.style.visibility == "visible" && ev.type == "keyup" && this.actualRows > 0) {
		if (!ev.ctrlKey && !ev.altKey && !ev.metaKey && !ev.shiftKey) {
			var amt;
			switch (keyCode) {
				case 38:		// up
					if (this.selectedIndex > 0)
						this.select(this.selectedIndex - 1);
					break;
				case 40:		// down
					if (this.selectedIndex + 1 < this.actualRows)
						this.select(this.selectedIndex + 1);
					break;
				case 9:			// tab
					this.onchoose();
					break;
				case 13:		// enter
					this.onchoose();
					break;
				case 33:		// PgUp
					amt = this.selectedIndex - (this.maxRows - 2);
					if (amt < 0)
						amt = 0;
					if (this.selectedIndex != amt)
						this.select(amt);
					break;
				case 34:		// PgDn
					amt = this.selectedIndex + (this.maxRows - 2);
					if (amt >= this.actualRows)
						amt = this.actualRows - 1;
					if (this.selectedIndex != amt)
						this.select(amt);
					break;
			}
		}
	}
}


// ***************
// PopupMenu class
// ***************

PopupMenu.prototype = new PopupList();
PopupMenu.prototype.constructor = PopupMenu;

// public - constructor
function PopupMenu() {
	// private
	this.menuList = null;
	this.eventKeyPress = this.menukeypress.bindAsEventListener(this);

	// public
	this.topMenuClassName = null;	// set this to the class to set the top item to when the menu is visible
	this.isRightClickMenu = false;
}



// private - used to clear out any circular refs
PopupMenu.prototype.unload = function() {
	this.unloadPopupMenu();
	this.unloadPopupList();
	this.unloadPopupDiv();
}

// private
PopupMenu.prototype.unloadPopupMenu = function() {
	this.div.hideTimer = null;
	this.menuList = null;
	this.eventKeyPress = null;
}

// public - how to draw items
PopupMenu.prototype.ondrawitem = function(index) {
	this.divs[index].innerHTML = this.items[index][0];
}

// fired when item picked
PopupMenu.prototype.onchoose = function() {
	this.div.hideTimer = setTimeout("if (document.getElementById('" + this.div.getAttribute("id") + "') != null) document.getElementById('" + this.div.getAttribute("id") + "').myPopup.hidePopup();", 100);
	var s = this.items[this.selectedIndex][1];
	if (s.indexOf("javascript:") == 0) {
		eval(s);
	}
	else {
		document.location = s;
	}
}

// internal
function PopupMenu_divmouseover() {
	if (this.hideTimer != null) {
		clearTimeout(this.hideTimer);
		this.hideTimer = null;
	}
	if (!this.myPopup.isRightClickMenu && this.myPopup.attachElement != null) {
		if (this.myPopup.topMenuClassName != null && this.myPopup.topMenuClassName != "")
			this.myPopup.attachElement.className = this.myPopup.topMenuClassName;
		else {
			this.myPopup.attachElement.style.backgroundColor = "lightsteelblue";
		}
	}
}

// internal
function PopupMenu_divmouseout() {
	this.hideTimer = setTimeout("if (document.getElementById('" + this.getAttribute("id") + "') != null) document.getElementById('" + this.getAttribute("id") + "').myPopup.hidePopup();", 100);
	
	if (!this.myPopup.isRightClickMenu && this.myPopup.attachElement != null) {
		if (this.myPopup.topMenuClassName != null && this.myPopup.topMenuClassName != "")
			this.myPopup.attachElement.className = "";
		else
			this.myPopup.attachElement.style.backgroundColor = "";
	}
}

// public - adds a menu, zero based
PopupMenu.prototype.addMenu = function(arrMenu) {
	if (this.menuList == null)
		this.menuList = new Array();
	this.menuList[this.menuList.length] = arrMenu;
}

// public - clears all menu items - used if you want to dynamically change contents of a menu
PopupMenu.prototype.clearMenu = function() {
	this.menuList = null;
}

// public - hide the menu
PopupMenu.prototype.hideMenu = function(obj) {
	//var id = this.div.getAttribute("id");
	//if (mydiv.myPopup.isRightClickMenu) {
		removeEvent(document, 'keypress', this.eventKeyPress);	
	//}
	
	this.div.hideTimer = setTimeout(this.reallyHideMenu.bind(this), 100);
}

PopupMenu.prototype.reallyHideMenu = function () {
	var mydiv = $(this.div.getAttribute("id"));
	if (mydiv && mydiv.myPopup) {
		mydiv.myPopup.hidePopup();
	}
}

// public - show the menu
// set optArr to array of menu item indexes to omit like [7, 9]
PopupMenu.prototype.showMenu = function(obj, top, newWidth, postype, optArr) {
	if (this.div.hideTimer != null) {
		clearTimeout(this.div.hideTimer);
		this.div.hideTimer = null;
	}
	//if (this.isRightClickMenu) {
		this.tagName = 'A';
		addEvent(document, 'keypress', this.eventKeyPress);
	//}
	//Event.observe(document,'keypress',this.eventKeyPress);
	
	if (top >= 0 && top < this.menuList.length) {
		this.div.onmouseover = PopupMenu_divmouseover;
		this.div.onmouseout = PopupMenu_divmouseout;
		this.div.onfocus = PopupMenu_divmouseover;
		if (this.isRightClickMenu) {
			this.div.onblur = PopupMenu_divmouseout;
		}

		if (optArr!=null || top != this.curMenu) {
			this.curMenu = top;
			if (newWidth != null)
				this.setWidth(newWidth);
			if (optArr != null) {
				var tmpArr = [];
				var s = "|" + optArr.join("|") + "|";
				for (var i = 0; i < this.menuList[top].length; i++) {
					if (s.indexOf("|" + i.toString() + "|") < 0) {
						tmpArr[tmpArr.length] = this.menuList[top][i];
					}
				}
				this.setItems(tmpArr);
			}
			else
				this.setItems(this.menuList[top]);
		}
		if (postype == null || postype == "")
			postype = "positionbelow";
		this.showPopup(null, postype, obj);
		if (this.focusFirstItem && this.divs && this.divs[0] && this.divs[0].focus) {
			var mydiv = this.divs[0];
			setTimeout(function () {mydiv.focus();}, 100);
		}
	}
	else {
		this.div.hideTimer = setTimeout(this.reallyHideMenu.bind(this), 100);
		return;
	}
}

// public - cancel the hide menu (needed to keep it up when mouse over tab)
PopupMenu.prototype.cancelHideMenu = function() {
	if (this.div.hideTimer != null) {
		clearTimeout(this.div.hideTimer);
		this.div.hideTimer = null;
	}
}

PopupMenu.prototype.menukeypress = function(ev) {
	if (this.isVisible) {
		ev = (ev) ? ev : window.event;
		var keyCode = (ev.which) ? ev.which : ev.keyCode;
		var div = this.div //(ev.target || ev.srcElement);
		//var mypoplist = div.getAttribute('mypoplist');
		//var position =  parseInt(div.getAttribute('position'), 10);
				
		if (!div) {
			return;
		}
		var position = this.selectedIndex;
		switch (keyCode)
		{	
			case 9:		// tab
				break;
			case 37:	// left
				break;
			case 39:	// right
				break;
			case 27:	//escape
				this.hideMenu();
				stopEvent(ev);
				break;
			case 13:
				this.onchoose();
				stopEvent(ev);
				return;
			case 38:	// up
				//OTDebugWrite('going up: ' + position)
				if (0 <= position - 1)
				{
					//this.divs[position - 1].focus();
					this.select(position - 1);
				}
				else if (this.divs && this.divs.length > 0){
					//this.divs[this.items.length-1].focus();
					this.select(this.items.length-1);
				}
				stopEvent(ev);				
				break;
			case 40:	// down
				//OTDebugWrite('going down: ' + position)
				if (this.divs && this.divs.length > 0)
				{
					if (this.items.length > position + 1) {
						//this.divs[position + 1].focus();
						this.select(position + 1);
					}
					else {
						this.select(0);
						//this.divs[0].focus();
					}
					stopEvent(ev);
				}
				break;
		}
	}
}


// otHelp class

var otHelp = null;

function otCreatePopupHelp() {
	otHelp = new otPopupDiv();
	otHelp.zIndex = 1001;
	otHelp.options = {
		showClose: false
		, width: "180px"
		, className: "popuphelp"
		, shadowClassName: "popupshadow"
		, title: OTGetUserMessage('SmallJs', 'OuttaskQuickHelp')
		, position: "positionbelow"
		, xOffset: 0
		, yOffset: 10
		, showEffect: 'grow'
		, effectDuration: .1
		, hackIEShadow : true
		, draggable: true
		, autoSize: false
	}
	// 508: Keyboard accessibility - set element to take focus on close
	if (CNQR.ConcurAccessible == true) otHelp.options.showClose = true;

	otHelp.showHelp = function(message, attachElement, helpOptions) {
		//set properties on the otHelp object to the various options
		//reason for doing it this way, is so we can re-use the same object each time
		//and the properties will be reset each time
		
		helpOptions = (helpOptions || {})

		for (opt in this.options) 
		{
			this[opt] = (helpOptions[opt] == null) ? this.options[opt] : helpOptions[opt];
		}
		
		var output = '<table width="100%">';
		if (this.title || this.showClose)
		{
			output += '<tr><td class="popuphelptitle" id="popuphelptitle" aria-live="assertive">' + this.title + '&nbsp;</td>';
			if (this.showClose) 
				output+= '<td align="right"><a href="javascript:void(0);" id="popuphelpclose" class="popuphelpclose" onclick="otHidePopupHelp();" onmouseover="this.className=\'popuphelpclose popuphelpcloseon\';" onmouseout="this.className=\'popuphelpclose\';">' + OTGetUserMessage("Common", "Close") + '</a></td>'
			output += '</tr>'
		}
		output += '<tr><td colspan="2"><div tabindex="-1" id="helpmessage">' + message + '</div></td></tr></table>'

		if (!$('othelpdiv'))
			otHelp.create("othelpdiv");
			
		if (attachElement && !this.showClose)
			addEvent(attachElement, "mouseout", otHidePopupHelp)


		otHelp.setWidth(this.width)
		
		otHelp.showPopup(output, this.position, attachElement);
		
		// 508: Focus div & announce title - quick help seems to need the explicit reloafing ot
		// the title to trigger announcing "alert" and the contents
		otHelp.onshow = function()
		{
			if (CNQR.ConcurAccessible == true)
			{
				$('othelpdiv').focus();
				if (this.title || this.showClose) $('othelpdiv').innerHTML = $('othelpdiv').innerHTML; // refresh contents so title is read
			}
		}
	}
}

function otShowPopupHelp(message, attachElement, helpOptions) {
	if (otHelp == null)
		otCreatePopupHelp();
	helpOptions = helpOptions || {};

	if (helpOptions.delay) {
		otHelp._timeout = window.setTimeout(function () {otHelp.showHelp(message, attachElement, helpOptions);}, helpOptions.delay);
	}
	else {
		otHelp.showHelp(message, attachElement, helpOptions);
	}
}

function otHidePopupHelp() {
	if (window['otHelp']) {
		if (otHelp._timeout) {
			clearTimeout(otHelp._timeout);
		}
		otHelp.hidePopup();
	}
}

// otPopupDialog class

var otPopupDialog = null;

function otCreatePopupDialog() {
	otPopupDialog = new otPopupDiv();
	otPopupDialog.zIndex = 999;
	otPopupDialog.options = {
		showClose: true
		, closeDisabled: false
		, width: "480px"
		, height: null /*auto set height*/
		, minHeight: 45 /* covers both the title and the status bar */
		, maxHeight: otPopupDialog.getWindowDimensions().height - 30
		, className: "popupdialog"
		, shadowClassName: "popupdialogshadow"
		, title: OTGetUserMessage('SmallJs', 'OuttaskPopupDialog')
		, position: "windowcenter"
		, xOffset: 0
		, yOffset: 10
		, showEffect: '' // no effects by default. they cause too many problems.
		, effectDuration: null
		, showWaitImage: false
		, draggable: true
		, dragHandle: 'popupdialogtitlebar'
		, destroyOnClose: false
		, hackIEShadow : true 
		, modal: false
		, autoSize: false
		, resizable: false
		, onButtonClick: null /*set this to a function callback */
		, contentAttachElement: null /*use this element from the DOM to append to this.div*/
		, buttons: []
		, icon: null
		, callOnClose: null
	}

	otPopupDialog.showDialog = function(message, attachElement, dialogOptions) {
		//set properties on the otPopupDialog object to the various options
		//reason for doing it this way, is so we can re-use the same object each time
		//and the properties will be reset each time

		dialogOptions = (dialogOptions || {})
		message = (message || '');

		//containerNode lets us set the parentNode of the popupDiv, which is useful for iframes or forms
		var containerNode = dialogOptions['containerNode'];
		if (containerNode) {
			if ($('otPopupDialogdiv')) {
				if (this.outerDiv.parentNode && this.outerDiv.parentNode != containerNode){
					this.outerDiv.parentNode.removeChild(this.outerDiv);
					containerNode.appendChild(this.outerDiv);
					this.destroyOnClose = true;
				}
			}
			delete dialogOptions['containerNode']; //no need to keep a reference to this
		}

		for (opt in this.options) {
			this[opt] = (dialogOptions[opt] == null) ? this.options[opt] : dialogOptions[opt];
		}
		
		var dragCls = (window['Draggable'] && this.draggable && this.dragHandle == 'popupdialogtitlebar') ? ' drag' : '';
		var output = "";
		if (this.title || this.showClose) {
			output += '<div id="popupdialogtitlebar" class="popupdialogtitlebar' + dragCls + '">';
			
			output += '<div class="popupdialogtitle heading4" id="popupdialogtitle" aria-live="assertive" tabindex="-1">' + this.title + '</div>';
			if (this.showClose) {
				if (this.closeDisabled) {
					output += '<div class="popupdialogclosedisabled"><div>&nbsp;</div></div>';
				} else {
					if (!CNQR.ConcurAccessible == true) {
						output += '<div class="popupdialogclose"><div onclick="	otHidePopupDialog();">&nbsp;</div></div>';
					} else {
						output += '<div class="popupdialogclose"><a href="javascript:void(0);" onclick="otHidePopupDialog();">' + OTGetUserMessage("Common", "Close") + '</a>&nbsp;</div>';
					}
				}
			}
			else {
				output += '<div class="popupdialogclose">&nbsp;</div>';
			}
			output += '</div>';
		}
		
		if (this.showWaitImage) {
			output += '<div id="otPopupDialogWaiting" aria-live="assertive"></div>';
		}
		else {
			output += '<div id="otPopupDialogWaiting" style="display:none" aria-live="assertive"></div>';
		}

		if (this.icon) {
			output += '<div id="otPopupDialogContents" class="' + this.icon + '" style="position:relative;" tabindex="-1" aria-live="assertive">';
			output += '<span class="offscreen">' + this.title + '</span>' + message + '</div>';
		}
		else {
			output += '<div id="otPopupDialogContents" style="position:relative;" tabindex="-1" aria-live="assertive">';
			output += '<span class="offscreen">' + this.title + '</span>' + message + '</div>';	
		}
		
		if (this.buttons.length) {
			output += '<div class="otPopupButtons" id="otPopupButtons">&nbsp;</div>';
		}	
		if (this.resizable) {
			output += '<div id="otPopupDialogStatus"><div class="popupdialogresize"><div id="popupdialogresizer">&nbsp;</div></div></div>';
		}

		if (!$('otPopupDialogdiv'))
			otPopupDialog.create("otPopupDialogdiv", containerNode);

		if (attachElement && !this.showClose)
			addEvent(attachElement, "mouseout", otHidePopupDialog)
			
		if (!this.buttons.length & this.showClose && CNQR.ConcurAccessible == true) {
			if (message.indexOf('<button') <= 0 && message.indexOf('type="button"') <= 0)
			{
				output+= '<div style="text-align:center"><button type="button" onclick="otHidePopupDialog();">' + OTGetUserMessage("Common", "Close") + '</button></div>';
			}
		}
		
		otPopupDialog.setWidth(this.width);
		otPopupDialog.setHTML(output); //do this now, so we'll have a DOM for items in the next step
				
		this.contentBody = $('otPopupDialogContents');
		this.statusBar = $('otPopupDialogStatus');
		
		this.resetHeight(); //needed to handle maxHeight. Has to be done after we set this.contentBody
		
		var elmDisplayOld = '';


		if (this.buttons.length) {
			var that = this;
			for (var i=0;i<this.buttons.length;i++) {
				var btnConfig = this.buttons[i];
				var newBtn = document.createElement("input");
				newBtn.type = "button";
				newBtn.id = (btnConfig.id || 'popupdialogBtn_' + i);
				btnConfig.text = (btnConfig.text || (btnConfig.messageid? OTGetUserMessage('common', btnConfig.messageid) : btnConfig.value));
				newBtn.value = btnConfig.text;
				$('otPopupButtons').appendChild(newBtn);
				addEvent(newBtn, 'click', function(e)
					{
						that.hideDialog = true;
						if (that.onButtonClick) {
							that.onButtonClick(this, that);
						}
						if (that.hideDialog === true) {
							that.hidePopup();
						}
					}.bindAsEventListener(btnConfig)
				);
			}
		}
		
		if (this.contentAttachElement) {
			this.contentAttachElement = $(this.contentAttachElement);
			this.contentAttachParent = this.contentAttachElement.parentNode;
			//this.contentAttachParent.removeChild(this.contentAttachElement); //apparently not needed
			elmDisplayOld = this.contentAttachElement.style.display;
			this.contentAttachElement.style.display = 'block';
			this.contentBody.appendChild(this.contentAttachElement);
			this.destroyOnClose = true;
			this.resetHeight();
		}


		if (this.resizable && window['Event']) //testing for prototype.js
		{
			//declare several private functions
			this._initDrag  = function(event) {
				// Get pointer X,Y
	  			this.pointer = [Event.pointerX(event), Event.pointerY(event)];
	  			this.autoSize = false; // don't resize based on the content
				
				// Get the start height and width. We'll resize based on mouse cursor and this value.
				this.doResize = true;
				
				this._startDragHeight = this.currentHeight;
				this._startDragWidth = this.currentWidth;
				
				this.oldBodyCursor = document.body.style.cursor;
				document.body.style.cursor = 'se-resize';
  				addEvent(document, "mouseup", this.eventMouseUp, false);
				addEvent(document, "mousemove", this.eventMouseMove, false);			
			}
		
			this._updateDrag = function(event) {
   				
   				var pointer = [Event.pointerX(event), Event.pointerY(event)];
				var dx = pointer[0] - this.pointer[0];
				var dy = pointer[1] - this.pointer[1];
				
				// Resize case, update width/height
				if (this.doResize) {

					this.height = this._startDragHeight + dy;
					this.width = this._startDragWidth + dx;

					this.resizeDiv();
									
					//dy = this.height - this._startDragHeight;
					//dx = this.width - this._startDragWidth;

				}
				/*
				if (this.iefix) 
					this._fixIEOverlapping(); 
					
				*/
				stopEvent(event);
			}

			 // endDrag callback
 			this._endDrag = function(event) {
				// Remove temporary div over iframes
 				//WindowUtilities.enableScreen('__invisible__');

				// Release event observing
				removeEvent(document, "mouseup", this.eventMouseUp,false);
				removeEvent(document, "mousemove", this.eventMouseMove, false);
				stopEvent(event); //Event.stop(event);
    
				// Restore selection
				document.body.style.cursor = this.oldBodyCursor;
				document.body.ondrag = null;
				document.body.onselectstart = null;
			}		
		
		
			this.eventMouseDown = this._initDrag.bindAsEventListener(this);
			this.eventMouseMove = this._updateDrag.bindAsEventListener(this);
			this.eventMouseUp   = this._endDrag.bindAsEventListener(this);
			
			this.resizer = $("popupdialogresizer");	
			this.resizer.onselectstart = function() {return false;}
    		addEvent(this.resizer, "mousedown", this.eventMouseDown);
		}

		if (this.destroyOnClose)
		{
			this.beforeOnHide = function()
			{
				if (this.contentAttachElement && this.contentAttachParent) {
					this.contentAttachElement.style.display = elmDisplayOld;
					this.contentAttachParent.appendChild(this.contentAttachElement);
				}
				this.unload();

				if (this.outerDiv.parentNode){
					this.outerDiv.parentNode.removeChild(this.outerDiv);
				}
				window['otPopupDialog'] = null;
			}		
		}
		this.resetHeight();
		otPopupDialog.showPopup(null, this.position, attachElement);
		
		// Section 508: Force user focus to div when opened. Only doing it for accessible because
		// don't want to show "focused" dotted line for all users				
		otPopupDialog.onshow = function()
		{
			popupDialog_onshow(this);
		}
	}



	otPopupDialog.setContents = function(html) {
		$("otPopupDialogContents").innerHTML = html;
		$("otPopupDialogContents").style.display = '';
		this.resetHeight();
	}

	otPopupDialog.hideWaitImage = function(bHideContent) {
		var el = $("otPopupDialogWaiting");
		if (el != null) {
			el.style.display = 'none';
		}
		if (bHideContent && this.contentBody) {
			this.contentBody.style.display = '';
		}
	}

	otPopupDialog.displayWaitImage = function(bShowContent) {
		var el = $("otPopupDialogWaiting");
		if (bShowContent && this.contentBody) {
			this.contentBody.style.display = 'none';
		}
		
		
		if (el != null) {
			el.style.display = 'block';
		}
		this.resetHeight();		
	}
}

function otShowPopupDialogWait(message, attachElement, dialogOptions) {
    if (otPopupDialog != null) {
        //alert("WAIT...");
        window.setTimeout(function() { otShowPopupDialog(message, attachElement, dialogOptions); }, 3000);
    }
    else {
        otCreatePopupDialog();
        otPopupDialog.showDialog(message, attachElement, dialogOptions);
    }
}

function otShowPopupDialog(message, attachElement, dialogOptions) {
	if (otPopupDialog && otPopupDialog.contentAttachElement && otPopupDialog.destroyOnClose) {
	 	// Save the attached form fields gracefully instead of destroying them with the new popup HTML!
		otPopupDialog.beforeOnHide(otPopupDialog);
	}
	if (otPopupDialog == null) {
		otCreatePopupDialog();
	}

	return otPopupDialog.showDialog(message, attachElement, dialogOptions);
}

function otSetPopupDialogContents(html) {
	if (window['otPopupDialog']) {
		otPopupDialog.hideWaitImage();
		otPopupDialog.setContents(html);
	}
}

function otResizePopupDialog() {
	if (window['otPopupDialog'])
		otPopupDialog.resetHeight();
}

function otPopupDialogWaiting(bShow, flipContentDisplay) {
	if (window['otPopupDialog']) {
		if (bShow)
			otPopupDialog.displayWaitImage(flipContentDisplay);
		else
			otPopupDialog.hideWaitImage(flipContentDisplay);
	}
}

function otHidePopupDialog() {
	if (window['otPopupDialog']) {
		otPopupDialog.hidePopup();
		if (document.frmMain && document.frmMain.disabled == true) document.frmMain.disabled = false;
	}
}

// used to load HTML resource data from a (presumably hidden) div and cache it
function otLoadPopupDialogHtml(elem) {
	if (otPopupDialog == null)
		otCreatePopupDialog();
	elem = $(elem);
	var name = '_c_' + elem.id;
	if (otPopupDialog[name] == null) {
		otPopupDialog[name] = elem.innerHTML;
		elem.innerHTML = "";
	}
	return otPopupDialog[name];
}

var otActionMenu = null;
	
function setupActionMenu() {
	otActionMenu = new PopupMenu();
	otActionMenu.itemClassName = "popupmenuitem";
	otActionMenu.selectedItemClassName = "popupmenuitemsel";
	otActionMenu.topMenuClassName = "popupvisible";
	otActionMenu.maxRows = 25;
	otActionMenu.create("actionMenuPopup");
	otActionMenu.setWidth("150px");
	otActionMenu.topMenuClassName = null;
	otActionMenu.isRightClickMenu = true;
	otActionMenu.focusFirstItem = true;
	if (typeof(pageSpecificActionMenuSetup) != 'undefined') {
		pageSpecificActionMenuSetup();
	}
}
		
function destroyActionMenu() {
	otActionMenu = null;
}
	
//OptArr is for what indexes to hide - see showMenu
function showActionMenu(link,top,rowID,optArr) {
	if (otActionMenu == null) {
		setupActionMenu();
		addEvent(window, "unload", destroyActionMenu, false);
	}
	
	otActionMenu.rowID = rowID;
		
	otActionMenu.showMenu(link,top,null,null,optArr);
}

CNQR.AjaxDialog = {
	Request: function(url, options) {
		var defaultOptions = {method:"get", onException: CNQR.AjaxDialog.Show, onException: CNQR.AjaxDialog.Show, onSuccess: CNQR.AjaxDialog.Show};
		options = Object.extend(defaultOptions, options || {});
		new Ajax.Request(url, options);
		addScript('/javascript/prototype/dragdrop.js'); //in functions.js
	}
	, Show: function(xmlhttpRequest, options) {
		var message = xmlhttpRequest.responseText;
		if (message == null) return;
		var defaultOptions = {title: '', attachElement: document.body, resizable: true, modal:true, destroyOnClose: true, minHeight:100};
		options = Object.extend(defaultOptions, options || {});	
		otShowPopupDialog(message, options.attachElement, options);
		message.evalScripts();
	}
	, showE: function(xmlHttp, e) {
		alert(e)
	}
	, AjaxifyForm: function (elementInForm, options, ajaxOptions) {
		elementInForm = $(elementInForm);
		var frm = elementInForm.up('form');
		var defaultOptions = {method:'post', asynchronous:true, evalScripts:true};
		ajaxOptions = Object.extend(defaultOptions, ajaxOptions || {});
		options = options || {};
		frm.onsubmit = function () {
			var opt = ajaxOptions;
			opt.parameters = Form.serialize(this);
			if (options.updateDiv) {
				var oldHeight = Element.getHeight(options.updateDiv);
				$(options.updateDiv).innerHTML = '<div style="height=' + oldHeight + 'px;"><div class="processing_icon">Loading</div></div>';
				var oldOnComplete = opt.onComplete || Prototype.emptyFunction;
				opt.onComplete = (function(transport, param) {
					otHidePopupDialog();
					if (window.Effect) {
						window.setTimeout(function () {new Effect.Highlight(options.updateDiv)}, 500);
					}
					oldOnComplete(transport, param);
				}).bind(this);
				new Ajax.Updater(options.updateDiv, frm.action, opt);				
			}
			else
			{
				var oldOnComplete = opt.onComplete || Prototype.emptyFunction;
				opt.onComplete = (function(transport, param) {
					otHidePopupDialog();
					oldOnComplete(transport, param);
				}).bind(this);
				
				new Ajax.Request(frm.action, opt);
			}
			return false;
		}
	}
}

// Section 508 - tracking calling element and handling keystrokes outde of active div
CNQR.keyLinkElement = null;
CNQR.popupLinkElement = null;

function popupDialog_onshow(objPopup)
{
	if (CNQR.ConcurAccessible == true)
	{
		if ($('otPopupDialogdiv') && $('otPopupDialogdiv').style.display != 'none') $('otPopupDialogdiv').focus();
		if (objPopup.title || objPopup.showClose) 
		{
			$('popupdialogtitle').innerHTML = $('popupdialogtitle').innerHTML + ' '; // refresh contents so title is read
		}
	}
	else
	{
		if(objPopup.buttons && objPopup.buttons.length == 1) tryFocus($('popupdialogBtn_0'));
	}
}

addEvent(window, 'load', function() {
	if (CNQR.ConcurAccessible == true)
	{
		Event.observe(document.body, 'keyup', function(event)
		{
			var keyCode = event.keyCode;
			switch (keyCode)
			{
				case Event.KEY_TAB:
				case Event.KEY_DOWN:
				case Event.KEY_UP:
				case 16: // shift
					var keypressHelp = $(Event.element(event)).up('div#outerothelpdiv');
					var keypressGeocode = $(Event.element(event)).up('div#outerGeocoderDiv');
					var keypressDialog = $(Event.element(event)).up('div#outerotPopupDialogdiv');
					var keypressOverdiv = $(Event.element(event)).up('div#overDiv');
					if (!keypressHelp && $('outerothelpdiv') && $('outerothelpdiv').style.visibility == 'visible')
					{
						$('popuphelpclose').focus();
						event.stop();
					}
					else if (!keypressGeocode && $('outerGeocoderDiv') && $('outerGeocoderDiv').style.visibility == 'visible')
					{
						$('outerGeocoderDiv').down('a').focus();
						event.stop();
					}
					else if (!keypressDialog && $('outerotPopupDialogdiv') && $('outerotPopupDialogdiv').style.visibility == 'visible')
					{
						$('outerotPopupDialogdiv').down('a').focus();
						event.stop();
					}
					else if (!keypressOverdiv && $('overDiv') && $('overDiv').style.visibility == 'visible')
					{
						if ($('actionclose')) $('actionclose').focus();
						event.stop();
					}
				case event.KEY_RETURN:
					if (!keypressHelp && !keypressGeocode && !keypressDialog)
					{
						CNQR.keyLinkElement = Event.element(event);
					}
			}

		});
	}
});